package com.gxa.client_shoppings.service.impl;

import com.gxa.client_shoppings.mapper.MenuMapper;
import com.gxa.client_shoppings.pojo.Menu;
import com.gxa.client_shoppings.service.MenuService;
import com.gxa.client_shoppings.utils.JsonResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author smile_ZhongXuan
 * @Date 2020/11/16 9:19
 * @Version 1.0
 */
@Service("menuService")
public class MenuServiceImpl implements MenuService {

    @Resource
    MenuMapper menuMapper = null;
    JsonResult jsonResult = new JsonResult();
    Menu menu = new Menu();

    @Override
    public Integer menuManagerAdd(Menu menu) {
        return menuMapper.insertSelective(menu);
    }

    @Override
    public Integer menuManagerUpdate(Menu menu) {
        return menuMapper.updateByPrimaryKeySelective(menu);
    }

    @Override
    public Integer menuManagerState(Integer id, Boolean state) {
        menu.setId(id);
        menu.setState(state);
        return menuMapper.updateByPrimaryKeySelective(menu);
    }

    @Override
    public Integer menuManagerDelete(Integer id) {
        menu.setId(id);
        return menuMapper.deleteByPrimaryKey(menu);
    }

    @Override
    public List menuManagerList() {
        return menuMapper.selectAll();
    }
}
